<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

    <!--扫描IOC注解-->
    <context:component-scan base-package="${dir}.service"></context:component-scan>

    <#if hasmybatis>
    <!--读取properties配置文件-->
    <context:property-placeholder location="classpath:*.properties" />
    <!-- 创建数据源  -->
    <bean id="datasource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="jdbcUrl" value="${url!}"></property>
        <property name="driverClass" value="${driver!}"></property>
        <property name="user" value="${username!}"></property>
        <property name="password" value="${pwd!}"></property>
        <property name="initialPoolSize" value="10"></property>
        <property name="maxPoolSize" value="50"></property>
    </bean>
    <!-- 创建session工厂 -->
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource"  ref="datasource"></property>
        <property name="configLocation" value="classpath:mybatis-config.xml" />
        <property name="mapperLocations" value="classpath:mapper/*.xml"></property>
    </bean>
    <!--  创建mapper映射 -->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="${dir}.mapper"></property>
    </bean>
    <!--  配置事务管理 -->
    <bean id="txmanager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="datasource"></property>
    </bean>
    <!-- 利用注解实现事务管理,激活事务注解 -->
    <tx:annotation-driven transaction-manager="txmanager"/>
    </#if>
</beans>